<%@page import="dao.MsgDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="model.SuGuan" %>
<%@ page import="java.util.List" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>宿管页面</title>

<link href="../css/Utils.css" rel="stylesheet" type="text/css" />
<link href="../css/List.css" rel="stylesheet" type="text/css" />
</head>
<body>

<!-- 头部 -->
<div class="header" ><br>
<nerong>&nbsp;&nbsp;宿管页面&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</nerong>

 <button onclick="confirmLogout('<%= (String)session.getAttribute("admin") %>','admin')">退出登录</button>

</div><br>

<div class="left" >
<table width="80%" height="80%">
<th>
<nerong>宿管可选择内容</nerong>

</th>
<tr>

<td bgcolor=#1a7dba>
<a>&emsp;个人信息</a><br>
</td>
</tr>

<tr>
<td>
<a href="../View_SuShe/SuSheSG_List.jsp">&emsp;楼栋学生信息查询</a><br>
</td>
</tr>
<tr>

<td>
<a href="../Veiw_fix/SgFix.jsp">&emsp;公物报修</a><br>

</td>
</tr>

<tr>
<td>
<a href = "../View_WeiGui/WeiGuiSG.jsp">&emsp;宿舍违规信息处理</a><br>
</td>
</tr>

</table>



</div>



<div class="context" >
<!-- 这部分是每个大功能的小功能 -->
 <table class="Alltable" >
  <caption>个人信息</caption>
   <thead>
      <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>身份</th>
         <th>操作</th>
        <!-- 个人信息是否需要显示密码列？ -->
        <!--<th>密码</th>-->
      </tr>
    </thead>
    <tbody align="center">
      <%
        MsgDao dao = new MsgDao();
        String id = (String) session.getAttribute("sg");
        if(id instanceof String){
        	String str=(String) id;
        	session.setAttribute("user",str);
        }
      
        List<SuGuan> users = dao.getAloneSuGuanMessage(id);
        if (users != null && !users.isEmpty()) {
          for (SuGuan user : users) {
      %>
      <tr>
        <td><%= user.getId() %></td>
        <td><%= user.getName() %></td>
        <td><%= user.getPower() %></td>
        
        <!--<td><%= user.getPassword() %></td>-->
        <td>
          <button onclick="location.href='../View_Msg/resetpsw.jsp?id=<%= user.getId() %>'">更改密码</button>
        </td>
      </tr>
      <%
          }
        } else {
      %>
      <tr>
        <td colspan="3">没有找到个人信息</td>
      </tr>
      <%
        }
      %>
      <!-- 错误显示： -->
      <%
        String error = (String) request.getAttribute("error");
        if (error != null) {
      %>
      <tr>
        <td colspan="3" style="color:red"><%= error %></td>
      </tr>
      <%
        }
      %>
    </tbody>
  </table>
</div>

</body>
</html>